Deleting an index permanently removes the records and the index configuration, like searchable attributes and custom ranking, from your Algolia application.

Instead of deleting the complete index, you can also delete (clear) just the records, keeping the configuration. See Clear records from an index on this page for more information.

Before you delete an index, consider creating a backup by exporting your index.

Deleting an index doesn’t affect its analytics data.

If you accidentally delete an index, the Algolia support team might be able to restore it but there are no guarantees. However, daily backups are included as part of the Enterprise pricing plan add-on.

Indices with replicas

If the index you want to delete is a replica of another index, you must first unlink it.

If the index is a primary index and has replicas, the replica indices will become independent indices if you delete their primary index.

Delete indices in the Algolia dashboard

To delete an index from the dashboard:

  1. Go to the Algolia dashboard and select your Algolia application.

  2. On the left sidebar, select Search.

  3. Select your Algolia index:

  4. Select Manage index > Delete.

  5. Type DELETE to confirm and click Delete.

Delete indices with the API

To delete an index, use one of these methods:

// Use an API key with `deleteIndex` ACL
var client = new SearchClient("YourApplicationID", "YourAPIKey");
var index = client.InitIndex("YourIndexName");

index.Delete();

// Asynchronous
await index.DeleteAsync();

Delete multiple indices

To delete more than one index:

  1. Use listIndices (API client) or algolia indices list (Algolia CLI) to get your indices
  2. Use multipleBatch or algolia indices delete to delete multiple indices with a single request.

To delete replica indices, you must first delete their primary indices.

using System;
using System.Collections.Generic;
using Algolia.Search.Clients;
using Algolia.Search.Models.Batch;
using Algolia.Search.Models.Enums;

namespace DeleteIndex
{
    class Program
    {
        static void Main(string[] args)
        {
            // You need an API key with `deleteIndex` permissions
            var client = new SearchClient("YourApplicationID", "YourAPIKey");

            // List all indices
            var indices = client.ListIndices().Items;
            var primaryIndices = new List<BatchOperation<string>>();
            var replicaIndices = new List<BatchOperation<string>>();

            foreach (var index in indices)
            {
                var action = new BatchOperation<string>
                {
                    IndexName = index.Name,
                    Action = BatchActionType.Delete
                };
                // Primary indices don't have a `Primary` key
                if (index.Primary == null)
                {
                    primaryIndices.Add(action);
                }
                else
                {
                    replicaIndices.Add(action);
                }
            }

            // Delete primary indices first
            if (primaryIndices.Count > 0)
            {
                client.MultipleBatch(primaryIndices).Wait();
                Console.WriteLine("Deleted primary indices.");
            }

            // Now, delete replica indices
            if (replicaIndices.Count > 0)
            {
                client.MultipleBatch(replicaIndices);
                Console.WriteLine("Deleted replica indices.");
            }
        }
    }
}

Clear records from an index in the Algolia dashboard

If you only want to delete (clear) the records from an index, keeping the index configuration, follow these steps:

  1. Go to the Algolia dashboard and select your Algolia application.

  2. On the left sidebar, select Search.

  3. Select your Algolia index:

  4. Select Manage index > Clear.

  5. Type CLEAR to confirm and click Clear.

Clear records from an index with the API

To remove only the records from the index, while keeping the settings, synonyms, and rules, use one of the following methods:

using System;
using Algolia.Search.Clients;

namespace ClearObjects
{
    class Program
    {
        static void Main(string[] args)
        {
            // You need an API key with `deleteIndex` permissions
            var client = new SearchClient("YourApplicationID", "YourAPIKey");

            var index = client.InitIndex("YourIndexName");
            index.ClearObjects();
            Console.WriteLine("Deleted records.");
        }
    }
}